package com.lc.redis.redisTemplate;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;

import javax.annotation.Resource;
import java.time.Duration;
import java.util.HashMap;
import java.util.concurrent.TimeUnit;

@SpringBootTest
public class StringType {
    @Resource
    private RedisTemplate redisTemplate;

    /**
     * 插入，查询
     */
    @Test
    public void testInsert(){
        redisTemplate.opsForValue().set("hello1","redis");
        Object hello = redisTemplate.opsForValue().get("hello1");
        System.out.println(hello);
    }

    /**
     * 设置过期时间
     */
    @Test
    public void testEXP(){
        redisTemplate.opsForValue().set("hello1","redis", 1,TimeUnit.MINUTES);
        Object hello1 = redisTemplate.opsForValue().get("hello1");
        System.out.println(hello1);
    }



}
